using System;
using System.Windows.Data;
using System.Windows.Media;

namespace GraphMyCode.Client.Utils
{
	public class ColorBrightnessConverter : IValueConverter
	{
		#region IValueConverter Members

		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			if (value == null)
				return Colors.Transparent;

			Color color = (Color)value;

			HslColor hsl = HslColor.FromColor(color);

			int offset = System.Convert.ToInt32(parameter);
			hsl = hsl.Lighten(offset / 100.0);

			return hsl.ToColor();
		}

		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			throw new NotImplementedException();
		}

		#endregion
	}
}